/*
 *  Copyright (C) 2009  Peter Kist & Jan Ripke
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "Injector.h"

#include <CEGUISystem.h>

namespace galaxy {
    namespace gfx {
        namespace ogre3d {
            namespace gui {

                Injector::Injector(void)
                {
                }

                Injector::Injector(CEGUI::System& system) : m_System (&system) {
                }

                Injector::~Injector(void)
                {
                }

                void Injector::injectMouseMove (float x, float y) {
                    m_System->injectMouseMove (x, y);
                }

                void Injector::injectMouseButtonDown (input::MouseButton mouseButton) {
                    CEGUI::MouseButton guiMouseButton = translateMouseButton (mouseButton);
                    if (guiMouseButton != CEGUI::NoButton) {
                        m_System->injectMouseButtonDown (guiMouseButton);
                    }
                }

                void Injector::injectMouseButtonUp (input::MouseButton mouseButton) {
                    CEGUI::MouseButton guiMouseButton = translateMouseButton (mouseButton);
                    if (guiMouseButton != CEGUI::NoButton) {
                        m_System->injectMouseButtonUp (guiMouseButton);
                    }
                }

                CEGUI::MouseButton Injector::translateMouseButton (input::MouseButton mouseButton) {
                    switch (mouseButton) {
                    case input::MOUSE_BUTTON_LEFT:
                        return CEGUI::LeftButton;
                    case input::MOUSE_BUTTON_MIDDLE:
                        return CEGUI::MiddleButton;
                    case input::MOUSE_BUTTON_RIGHT:
                        return CEGUI::RightButton;
                    case input::MOUSE_BUTTON_NONE:
                        return CEGUI::NoButton;
                    }
                    return CEGUI::NoButton;
                }

            } // namespace gui
        } // namespace ogre3d
    } // namespace gfx
} // namespace galaxy

